﻿using System;
using Cms.Application.Admin.Presenters;
using Cms.Application.Admin.Views;
using Cms.Web.Framework.Controls;
using iLib.Web.UI;

namespace Cms.Web.UI.Admin
{
    public partial class UploadFiles : AdminPage, IUploadView
    {
        private UploadPresenter _presenter;

        #region IUploadView Members

        public string ContextTranslationFile
        {
            get { return "Admin/Translations/Upload.xml"; }
        }


        public void SetFolderName(string name)
        {
            litFolder.Text = name;
        }

        #endregion

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _presenter = new UploadPresenter(this);
            HeadingText = GetText(this, "Heading");
            if (!Page.IsPostBack)
            {
                HeadingIcon = litIcon.Text;
                hlCancel.NavigateUrl = "Admin/Media.aspx";
                if (!string.IsNullOrEmpty(Request.QueryString["browseitemdata"]))
                    hlCancel.NavigateUrl += "?browseitemdata=" + Server.UrlEncode(Request.QueryString["browseitemdata"]);
            }
            string script = "function displayOverwriteConfirmation(existingFiles) { " +
                            "document.getElementById('lblExistingFiles').innerHTML = existingFiles;" +
                            "cms.Dialogs.Confirm(validationCallback, '" + GetText(this, "OverwriteHeader") +
                            "', null, '" + GetText(this, "OverwriteOK") + "', '" + GetText(this, "OverwriteCancel") +
                            "', true, null, 'overwriteWarning');" +
                            "}";
            ClientScriptProxy.Current.RegisterClientScriptBlock(this, GetType(), "validate", script, true);
            ifrCheckFiles.Attributes.Add("src", "Admin/UploadCheck.aspx");
        }
    }
}